package com.walsai.pcsys.core.dao.hibernate;

import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;

import com.walsai.pcsys.core.dao.ProblemDao;
import com.walsai.pcsys.core.model.Problem;
import com.walsai.pcsys.core.model.Solution;

public class ProblemDaoHibernate extends GenericDaoHibernate<Problem, Long> implements
		ProblemDao {

	public ProblemDaoHibernate() {
		super(Problem.class);
		// TODO Auto-generated constructor stub
	}

	@Override
	public List<Problem> getPrivateProblems() {
		Session s = this.getSession();
		List<Problem> list = null;
		try {
			list = s.createCriteria(Problem.class).add(Restrictions.eq("permission", 1)).list();
		} catch (HibernateException e) {
			e.printStackTrace();
		} finally {
			if (s != null) {
				try {
					s.close();
				} catch (HibernateException e) {
					e.printStackTrace();
				}
			}
		}

		return list;
	}




}
